import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt+hj+IhIptnyvZO/FG3q
9iz0eIjWcnevSMpYQWggWfsorYntgJePciUMMFMS/SmlTFShhi+jq2z7QiBQn8Yb
zMcCIJrNosVPfo51HSclO1D5bKpU7pW/gahYUKz5yVPTBMOOKEx8uYYAwh4BBem6
RRk53G/Syb6gOj/ThEEIYAqBzwmqqO8LL28vn0U14eo1htVebkua1cAS5ct8XYKl
YiIH/xpWT96Qrny3VOW+zGrhwVGOYCxucifLSCPPfXGH6Okp0dIX1+GZ37leKk0F
Fr72vAGBzjS54w3JozOGdvIWePLEQdmeKtk35XZQ+G67JgGy3wdziUHc1AhFO2BU
1QIDAQAB`

const privateKey = `MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC36GP4iEim2fK9
k78Uber2LPR4iNZyd69IylhBaCBZ+yitie2Al49yJQwwUxL9KaVMVKGGL6OrbPtC
IFCfxhvMxwIgms2ixU9+jnUdJyU7UPlsqlTulb+BqFhQrPnJU9MEw44oTHy5hgDC
HgEF6bpFGTncb9LJvqA6P9OEQQhgCoHPCaqo7wsvby+fRTXh6jWG1V5uS5rVwBLl
y3xdgqViIgf/GlZP3pCufLdU5b7MauHBUY5gLG5yJ8tII899cYfo6SnR0hfX4Znf
uV4qTQUWvva8AYHONLnjDcmjM4Z28hZ48sRB2Z4q2TfldlD4brsmAbLfB3OJQdzU
CEU7YFTVAgMBAAECggEAH41zeXSIYngKOZRbuDmTkmDsILH5ePIn1KlCsxYWVtnM
hNmhMerO5ZqNmMzn+R9oCMyMWeVag1LTWOkKbB8lLeEG8Gke1spbdS8j0Liinqap
5Ibkw3pVvP0RCeZjhLMpBSw3+5oD3CCtiKB1NHqBRtGpJ7TXyV03SEcjFxHBShi4
wuNHKLmJmOjntcTSIvYay+mpPsxqG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new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

